import type { CreateCrudOptionsRet } from '@fast-crud/fast-crud';

import { dict } from '@fast-crud/fast-crud';

import { DefTenantApi } from '#/api';
import { TenantStatusEnum } from '#/enums/system';
import { $t } from '#/locales';

export function createCrudOptions(): CreateCrudOptionsRet {
  return {
    crudOptions: {
      request: {
        editRequest: DefTenantApi.updateStatusRequest,
      },
      form: { mode: 'edit', col: { span: 24 } },
      columns: {
        id: {
          title: $t('devOperation.tenant.defUser.username'),
          type: 'text',
          form: { show: false },
        },
        status: {
          title: '审核状态',
          type: 'dict-radio',
          form: { value: TenantStatusEnum.AGREED, rule: [{ required: true }] },
          dict: dict({
            data: [
              {
                label: '同意',
                value: TenantStatusEnum.AGREED,
              },
              {
                label: '拒绝',
                value: TenantStatusEnum.REFUSE,
              },
            ],
          }),
        },
        reviewComments: {
          title: '审批意见',
          type: 'textarea',
        },
      },
    },
  };
}
